
#import "WWImageButton.h"
#import "WWImageButtonCell.h"

@implementation WWImageButton

static id myStoredCellClass;


+ initialize 
{ 
  [WWImageButton setVersion:1]; 

  if (self == [WWImageButton class])
  {  myStoredCellClass = [WWImageButtonCell class];
  }

  return self; 
}
//
+ setCellClass:classID
{
  myStoredCellClass = classID;
  return self;
}
////////////////////////////////////////////////////////
- initFrame:(const NXRect *)frameRect icon:(const char *)aString tag:(int)anInt target:anObject action:(SEL)aSelector key:(unsigned short)charCode enabled:(BOOL)flag
{
  id  oldCell;


  [super initFrame:frameRect icon:aString tag:anInt target:anObject action:aSelector key:charCode enabled:flag];
  oldCell = [self setCell:[[WWImageButtonCell alloc] init]];
  [oldCell free];
  [self setOpaque:NO];
  return self;
}
//
- initFrame:(const NXRect *)frameRect title:(const char *)aString tag:(int)anInt target:anObject action:(SEL)aSelector key:(unsigned short)charCode enabled:(BOOL)flag
{
  id  oldCell;


  [super initFrame:frameRect title:aString tag:anInt target:anObject action:aSelector key:charCode enabled:flag];
  oldCell = [self setCell:[[myStoredCellClass alloc] init]];
  [oldCell free];
  [self setOpaque:NO];
  return self;
}
//
- init
{
  id  oldCell;


  [super init];
  oldCell = [self setCell:[[myStoredCellClass alloc] init]];
  [oldCell free];
  [self setOpaque:NO];
  return self;
}

- setIcon:(const char *)iconName
{
  [super setIcon:iconName];
  [[[self image] bestRepresentation] setOpaque:NO];
  return self;
}

- setImage:theImage
{
  [super setImage:theImage];
  [[[self image] bestRepresentation] setOpaque:NO];
  return self;
}

- setAltIcon:(const char *)iconName
{
  [super setAltIcon:iconName];
  [[[self altImage] bestRepresentation] setOpaque:NO];
  return self;
}

- setAltImage:theImage
{
  [super setImage:theImage];
  [[[self altImage] bestRepresentation] setOpaque:NO];
  return self;
}

@end
